<?php
	$shiftName = $_POST['shiftName'];

	$conn = new mysqli('localhost', 'root', '', 'sevenbits');
    $sql = "INSERT INTO shifts (ShiftName) VALUES ('$shiftName')";
    $conn->query($sql);
	
	$sql = "SELECT * FROM shifts";
	$result = $conn->query($sql);
	// if the $result contains at least one row
	if ($result->num_rows > 0) {
		$arrResults = array();
	  // output data of each row from $result
	  while($row = $result->fetch_assoc()) {
		$arrResults[] = array(
			'ShiftID' => $row['ShiftID'],
			'ShiftName' => $row['ShiftName']);
		// echo '<br /> id: '. $row['ShiftID']. ' - name: '. $row['ShiftName'] ;
	  }
	}
	echo json_encode($arrResults);
?>